package com.situ.water_read.controller;


import com.situ.water_read.pojo.RdYearmonth;
import com.situ.water_read.service.RdYearmonthService;
import com.situ.water_system.pojo.SyEmp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Angel
 * @since 2020-12-01
 */
@RestController
@RequestMapping("/rd-yearmonth")
public class RdYearmonthController {
    @Autowired
    private RdYearmonthService service;
    @PostMapping("/updateRdYear")
    public void updateRdYear(String str, HttpServletRequest request){
        SyEmp user = (SyEmp) request.getSession().getAttribute("user");
        if(user==null){
            service.addYearMouth(str, 7);
        }
        else {
            user.setId(7);
            service.addYearMouth(str, user.getId());
        }

    }
    @GetMapping("/queryall")
    public List<RdYearmonth> queryall(){

       List<RdYearmonth> list=service.queryYearmonth();
       return list;
    }
    @GetMapping("queryyearall")
    public List<Map> queryyearall(){

        List<Map> list=service.queryall();
        return list;
    }
}

